<?php
namespace app\home\home;

use think\Loader;

//引入WxPayPubHelper
loader::import('Wxpay.WxClient',EXTEND_PATH);
include_once EXTEND_PATH.'phpqrcode/qrcode.php';

class Wxpayapi
{

    //获取微信支付二维码
    public static function getCode($order_info,$is_base64=true){
        $weixinpay = new \WxHelper(config('wxpay_config'));
        $body           = $order_info['title'];             //商品描述
        $out_trade_no   = $order_info['order_sn'];                //商户订单号
        $total_fee      = $order_info['total_money']*100;
        $product_id     = $order_info['chargeid'];         //商品ID
        $notify_url     = config('wxpay_config')['notify_url'];
        $ext=null;

        $result_weixin  = $weixinpay->getCodeUrl($body, $out_trade_no, $total_fee, $notify_url, $product_id);

        $text= urldecode($result_weixin);
        $level=0;
        $size=10;
        $padding=1;
        $result_weixin =  \QRcode::png($text,FALSE,$level,$size,$padding,false,$is_base64);

        return $result_weixin;
    }

    //相应微信支付二维码
    public function notify(){
        $weixinpay =  new \WxHelper(config('wxpay_config'));
        $data=$weixinpay->getNotifyData();
        return $data;
    }

}